// Tags:
#include <cstdio>

typedef long long ll;
int t;
ll a, b, c;

ll exgcd(ll a, ll b, ll &x, ll &y) {
  if (!b) return x = 1, y = 0, a;
  ll tmp = exgcd(b, a % b, y, x);
  y -= (a / b) * x;
  return tmp;
}

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#else
  freopen("fuction.in", "r", stdin);
  freopen("fuction.out", "w", stdout);
#endif
#endif

  scanf("%d", &t);
  while (t--) {
    scanf("%lld%lld%lld", &a, &b, &c);
    if (b < 0) a = -a, b = -b, c = -c;
    ll x, y;
    ll gcd = exgcd(a, b, x, y), mod, tx;
    ll ans;
    if (!gcd) puts("ZenMeZheMeDuo");
    else {
      if (c % gcd) puts("0");
      else {
        if (a == 0 || b == 0)
          puts((c % (a + b) || c / (a + b) <= 0) ? "0" : "ZenMeZheMeDuo");
        else {
          x *= c / gcd;
          mod = b / gcd;
          x %= mod, x += mod, x %= mod;
          if (x == 0) x += mod;
          y = (c - a * x) / b;
          if (1ll * a * b < 0) {
            puts("ZenMeZheMeDuo");
          } else if (y <= 0) {
            puts("0");
          } else {
            tx = x;
            mod = a / gcd;
            y %= mod, y += mod, y %= mod;
            if (y == 0) y += mod;
            x = (c - b * y) / a;
            ans = (x - tx) / (b / gcd) + 1;
            if (ans > 65535) puts("ZenMeZheMeDuo");
            else
              printf("%lld\n", ans);
          }
        }
      }
    }
  }
  return 0;
}